import type * as Merchant from './type'
import http from '@/utils/http'

const BASE_URL = '/merchant/account'

/** @desc 查询商户列表列表 */
export function listAccount(query: Merchant.AccountPageQuery) {
  return http.get<PageRes<Merchant.AccountResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询商户列表详情 */
export function getAccount(id: string) {
  return http.get<Merchant.AccountDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增商户列表 */
export function addAccount(data: any) {
  return http.post(`${BASE_URL}/register`, data)
}

/** @desc 修改商户列表 */
export function updateAccount(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除商户列表 */
export function deleteAccount(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 冻结商户 */
export function freezeAccount(id: string) {
  return http.patch(`${BASE_URL}/${id}/freeze`)
}

/** @desc 解冻商户 */
export function unFreezeAccount(id: string) {
  return http.patch(`${BASE_URL}/${id}/unfreeze`)
}

/** @desc 修改密码 */
export function updateAccountPassword(data: any, id: string) {
  return http.patch(`${BASE_URL}/${id}/update/password`, data)
}

/** @desc 重置密码 */
export function resetAccountPassword(data: any, id: string) {
  return http.patch(`${BASE_URL}/${id}/reset/password`, data)
}

/** @desc 导出商户列表 */
export function exportAccount(query: Merchant.AccountQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
